package com.hsjk.szwj.module.train.dal.mysql.course;

import com.hsjk.szwj.framework.common.pojo.PageResult;
import com.hsjk.szwj.framework.mybatis.core.mapper.BaseMapperX;
import com.hsjk.szwj.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.hsjk.szwj.module.train.controller.admin.vo.AdminCourseLivePageReqVO;
import com.hsjk.szwj.module.train.controller.admin.vo.AdminCourseLiveSearchPageReqVO;
import com.hsjk.szwj.module.train.dal.dataobject.course.CourseLiveDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.Arrays;

@Mapper
public interface ICourseLiveMapper extends BaseMapperX<CourseLiveDO> {
    default PageResult<CourseLiveDO> selectPage(AdminCourseLivePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CourseLiveDO>()
                .likeIfPresent(CourseLiveDO::getLiveName, reqVO.getLiveName())
                .eqIfPresent(CourseLiveDO::getLiveType, reqVO.getLiveType())
                .orderByDesc(Arrays.asList(CourseLiveDO::getCreateTime, CourseLiveDO::getCreateTime)));
    }

    default PageResult<CourseLiveDO> selectPage(AdminCourseLiveSearchPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CourseLiveDO>()
                .eqIfPresent(CourseLiveDO::getLiveName, reqVO.getLiveName())
                .orderByDesc(Arrays.asList(CourseLiveDO::getCreateTime, CourseLiveDO::getCreateTime)));
    }
}
